<?php

/**
 * Application Models
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 * @copyright ZF model generator
 * @license http://framework.zend.com/license/new-bsd     New BSD License
 */

/**
 * Abstract class for models
 */
require_once 'ModelAbstract.php';

/**
 * 
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 */
class Application_Model_Governeras extends Application_Model_ModelAbstract
{

    /**
     * Database var type int(11)
     *
     * @var int
     */
    protected $_Idgoverneras;

    /**
     * Database var type int(11)
     *
     * @var int
     */
    protected $_Idperegov;

    /**
     * Database var type varchar(45)
     *
     * @var string
     */
    protected $_Idtypegovernera;

    /**
     * Database var type text
     *
     * @var text
     */
    protected $_Name;

    /**
     * Database var type text
     *
     * @var text
     */
    protected $_Geocoord;


    /**
     * Parent relation fk_governeras_governeras1
     *
     * @var Application_Model_Governeras
     */
    protected $_GovernerasByIdperegov;

    /**
     * Parent relation fk_governeras_typegovernera1
     *
     * @var Application_Model_Typegovernera
     */
    protected $_Typegovernera;


    /**
     * Dependent relation fk_governeras_governeras1
     * Type: One-to-Many relationship
     *
     * @var Application_Model_Governeras
     */
    protected $_Governeras;

    /**
     * Dependent relation fk_projetregional_governeras1
     * Type: One-to-Many relationship
     *
     * @var Application_Model_Projetregional
     */
    protected $_Projetregional;

    /**
     * Dependent relation fk_users_governeras1
     * Type: One-to-Many relationship
     *
     * @var Application_Model_Users
     */
    protected $_Users;

    /**
     * Sets up column and relationship lists
     */
    public function __construct()
    {
        parent::init();
        $this->setColumnsList(array(
            'idgoverneras'=>'Idgoverneras',
            'idperegov'=>'Idperegov',
            'idtypegovernera'=>'Idtypegovernera',
            'name'=>'Name',
            'geocoord'=>'Geocoord',
        ));

        $this->setParentList(array(
            'FkGovernerasGoverneras1'=> array(
                    'property' => 'GovernerasByIdperegov',
                    'table_name' => 'Governeras',
                ),
            'FkGovernerasTypegovernera1'=> array(
                    'property' => 'Typegovernera',
                    'table_name' => 'Typegovernera',
                ),
        ));

        $this->setDependentList(array(
            'FkGovernerasGoverneras1' => array(
                    'property' => 'Governeras',
                    'table_name' => 'Governeras',
                ),
            'FkProjetregionalGoverneras1' => array(
                    'property' => 'Projetregional',
                    'table_name' => 'Projetregional',
                ),
            'FkUsersGoverneras1' => array(
                    'property' => 'Users',
                    'table_name' => 'Users',
                ),
        ));
    }

    /**
     * Sets column idgoverneras
     *
     * @param int $data
     * @return Application_Model_Governeras
     */
    public function setIdgoverneras($data)
    {
        $this->_Idgoverneras = $data;
        return $this;
    }

    /**
     * Gets column idgoverneras
     *
     * @return int
     */
    public function getIdgoverneras()
    {
        return $this->_Idgoverneras;
    }

    /**
     * Sets column idperegov
     *
     * @param int $data
     * @return Application_Model_Governeras
     */
    public function setIdperegov($data)
    {
        $this->_Idperegov = $data;
        return $this;
    }

    /**
     * Gets column idperegov
     *
     * @return int
     */
    public function getIdperegov()
    {
        return $this->_Idperegov;
    }

    /**
     * Sets column idtypegovernera
     *
     * @param string $data
     * @return Application_Model_Governeras
     */
    public function setIdtypegovernera($data)
    {
        $this->_Idtypegovernera = $data;
        return $this;
    }

    /**
     * Gets column idtypegovernera
     *
     * @return string
     */
    public function getIdtypegovernera()
    {
        return $this->_Idtypegovernera;
    }

    /**
     * Sets column name
     *
     * @param text $data
     * @return Application_Model_Governeras
     */
    public function setName($data)
    {
        $this->_Name = $data;
        return $this;
    }

    /**
     * Gets column name
     *
     * @return text
     */
    public function getName()
    {
        return $this->_Name;
    }

    /**
     * Sets column geocoord
     *
     * @param text $data
     * @return Application_Model_Governeras
     */
    public function setGeocoord($data)
    {
        $this->_Geocoord = $data;
        return $this;
    }

    /**
     * Gets column geocoord
     *
     * @return text
     */
    public function getGeocoord()
    {
        return $this->_Geocoord;
    }

    /**
     * Sets parent relation Idperegov
     *
     * @param Application_Model_Governeras $data
     * @return Application_Model_Governeras
     */
    public function setGovernerasByIdperegov(Application_Model_Governeras $data)
    {
        $this->_GovernerasByIdperegov = $data;

        $primary_key = $data->getPrimaryKey();
        if (is_array($primary_key)) {
            $primary_key = $primary_key['idgoverneras'];
        }

        $this->setIdperegov($primary_key);

        return $this;
    }

    /**
     * Gets parent Idperegov
     *
     * @param boolean $load Load the object if it is not already
     * @return Application_Model_Governeras
     */
    public function getGovernerasByIdperegov($load = true)
    {
        if ($this->_GovernerasByIdperegov === null && $load) {
            $this->getMapper()->loadRelated('FkGovernerasGoverneras1', $this);
        }

        return $this->_GovernerasByIdperegov;
    }

    /**
     * Sets parent relation Idtypegovernera
     *
     * @param Application_Model_Typegovernera $data
     * @return Application_Model_Governeras
     */
    public function setTypegovernera(Application_Model_Typegovernera $data)
    {
        $this->_Typegovernera = $data;

        $primary_key = $data->getPrimaryKey();
        if (is_array($primary_key)) {
            $primary_key = $primary_key['idtypegovernera'];
        }

        $this->setIdtypegovernera($primary_key);

        return $this;
    }

    /**
     * Gets parent Idtypegovernera
     *
     * @param boolean $load Load the object if it is not already
     * @return Application_Model_Typegovernera
     */
    public function getTypegovernera($load = true)
    {
        if ($this->_Typegovernera === null && $load) {
            $this->getMapper()->loadRelated('FkGovernerasTypegovernera1', $this);
        }

        return $this->_Typegovernera;
    }

    /**
     * Sets dependent relations fk_governeras_governeras1
     *
     * @param array $data An array of Application_Model_Governeras
     * @return Application_Model_Governeras
     */
    public function setGoverneras(array $data)
    {
        $this->_Governeras = array();

        foreach ($data as $object) {
            $this->addGoverneras($object);
        }

        return $this;
    }

    /**
     * Sets dependent relations fk_governeras_governeras1
     *
     * @param Application_Model_Governeras $data
     * @return Application_Model_Governeras
     */
    public function addGoverneras(Application_Model_Governeras $data)
    {
        $this->_Governeras[] = $data;
        return $this;
    }

    /**
     * Gets dependent fk_governeras_governeras1
     *
     * @param boolean $load Load the object if it is not already
     * @return array The array of Application_Model_Governeras
     */
    public function getGoverneras($load = true)
    {
        if ($this->_Governeras === null && $load) {
            $this->getMapper()->loadRelated('FkGovernerasGoverneras1', $this);
        }

        return $this->_Governeras;
    }

    /**
     * Sets dependent relations fk_projetregional_governeras1
     *
     * @param array $data An array of Application_Model_Projetregional
     * @return Application_Model_Governeras
     */
    public function setProjetregional(array $data)
    {
        $this->_Projetregional = array();

        foreach ($data as $object) {
            $this->addProjetregional($object);
        }

        return $this;
    }

    /**
     * Sets dependent relations fk_projetregional_governeras1
     *
     * @param Application_Model_Projetregional $data
     * @return Application_Model_Governeras
     */
    public function addProjetregional(Application_Model_Projetregional $data)
    {
        $this->_Projetregional[] = $data;
        return $this;
    }

    /**
     * Gets dependent fk_projetregional_governeras1
     *
     * @param boolean $load Load the object if it is not already
     * @return array The array of Application_Model_Projetregional
     */
    public function getProjetregional($load = true)
    {
        if ($this->_Projetregional === null && $load) {
            $this->getMapper()->loadRelated('FkProjetregionalGoverneras1', $this);
        }

        return $this->_Projetregional;
    }

    /**
     * Sets dependent relations fk_users_governeras1
     *
     * @param array $data An array of Application_Model_Users
     * @return Application_Model_Governeras
     */
    public function setUsers(array $data)
    {
        $this->_Users = array();

        foreach ($data as $object) {
            $this->addUsers($object);
        }

        return $this;
    }

    /**
     * Sets dependent relations fk_users_governeras1
     *
     * @param Application_Model_Users $data
     * @return Application_Model_Governeras
     */
    public function addUsers(Application_Model_Users $data)
    {
        $this->_Users[] = $data;
        return $this;
    }

    /**
     * Gets dependent fk_users_governeras1
     *
     * @param boolean $load Load the object if it is not already
     * @return array The array of Application_Model_Users
     */
    public function getUsers($load = true)
    {
        if ($this->_Users === null && $load) {
            $this->getMapper()->loadRelated('FkUsersGoverneras1', $this);
        }

        return $this->_Users;
    }

    /**
     * Returns the mapper class for this model
     *
     * @return Application_Model_Mapper_Governeras
     */
    public function getMapper()
    {
        if ($this->_mapper === null) {
            $this->setMapper(new Application_Model_Mapper_Governeras());
        }

        return $this->_mapper;
    }

    /**
     * Deletes current row by deleting the row that matches the primary key
     *
	 * @see Application_Model_Mapper_Governeras::delete
     * @return int|boolean Number of rows deleted or boolean if doing soft delete
     */
    public function deleteRowByPrimaryKey()
    {
        if ($this->getIdgoverneras() === null) {
            throw new Exception('Primary Key does not contain a value');
        }

        return $this->getMapper()
                    ->getDbTable()
                    ->delete('idgoverneras = ' .
                             $this->getMapper()
                                  ->getDbTable()
                                  ->getAdapter()
                                  ->quote($this->getIdgoverneras()));
    }
}
